﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YmtAuth.Domain.DomainService
{
    public class AuthTokenFactory
    {
        private static readonly IDictionary<string, Func<AbstractAuthTokenStrategy>> authTokenDic = new Dictionary<string, Func<AbstractAuthTokenStrategy>> 
       {
           {"mainsite",()=>new MainAuthToken()},
           {"app",()=>new AppAuthToken()},
           {"matouapp",()=>new MatouAppAuthToken()},
           {"default",()=>new MainAuthToken()},
       };

        public static AbstractAuthTokenStrategy Factory(string requestSource)
        {
            var source = string.IsNullOrEmpty(requestSource) ? "default" : requestSource.ToLower();
            Func<AbstractAuthTokenStrategy> auth ;
            authTokenDic.TryGetValue(source, out auth);
            return auth == null ? new MainAuthToken() : auth();
        }
    }
}
